package com.weiqk.pmdemo.controller;

import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.alibaba.excel.EasyExcel;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.weiqk.pmdemo.controller.R.R;
import com.weiqk.pmdemo.dto.PayLinkInDto;
import com.weiqk.pmdemo.dto.PurchaseLinkInDto;
import com.weiqk.pmdemo.excel.ExcelListener;
import com.weiqk.pmdemo.pojo.Project;
import com.weiqk.pmdemo.service.PurchaseLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Api(tags="采购环节接口")
@Slf4j
@RestController
@RequestMapping("/PurchaseLink")
public class PurchaseLinkController {
    @Autowired
    PurchaseLinkService purchaseLinkService;
    @ApiOperation("获取全部")
    @ApiOperationSupport(author = "EDSION")
    @GetMapping("/getAll")
    @ResponseBody
    public R GetAll(){
        R r = new R();
        r.setData(purchaseLinkService.findAll());
        r.setS(true);
        return r;
    }
    @ApiOperation("根据id删除")
    @ApiOperationSupport(author = "EDSION")
    @DeleteMapping("/{id}")
    @ResponseBody
    public R DeleteById(@PathVariable Integer id){
        R r = new R();
        r.setS(purchaseLinkService.deleteById(id));
        return r;
    }
    @ApiOperation("更新")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("update")
    @ResponseBody
    public R Update(@RequestBody PurchaseLinkInDto purchaseLinkInDto){
        R r = new R();
        r.setS(purchaseLinkService.update(purchaseLinkInDto));
        return r;
    }
    @ApiOperation("新增")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("put")
    @ResponseBody
    public R Put(@RequestBody PurchaseLinkInDto purchaseLinkInDto){
        R r = new R();
        r.setS(purchaseLinkService.put(purchaseLinkInDto));
        return r;
    }

}
